package DesignPattern.Structure.Flyweight;

import java.util.HashMap;

public class BoxFactory {
    private HashMap<String, AbstractBox> map;

    private BoxFactory() {
        map = new HashMap<String, AbstractBox>();
        map.put("I", new IBox());
        map.put("L", new LBox());
        map.put("O", new OBox());
    }

    // 提供一个方法获取该工厂类对象
    public static BoxFactory getInstance() {
        return bf;
    }

    private static BoxFactory bf = new BoxFactory();

    // 根据名称获取图形对象
    public AbstractBox getBox(String key) {
        return map.get(key);
    }
}
